package csce482.groupgraffiti.com;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;

public class Login extends Activity {

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	
	    setContentView(R.layout.login);
	}
	
	// Try to log in with the provided credentials
	public void onLoginClick(View view) {
		if (attemptLogin("", "")){
			// Set the newly logged in user to the current user
			GroupGraffitiApp gga = (GroupGraffitiApp)getApplicationContext();
			EditText et = (EditText)findViewById(R.id.username);
			gga.username = et.getText().toString();
			gga.loggedIn = true;
			
			// Navigate to the home screen
			Intent intent = new Intent(Login.this, Home.class);
			startActivity(intent);
		}
		else {
			// can't fail for now
		}
		
	}
	
	// Try to authenticate the user
	// TODO: talk to balazs about how to do this, then do it!
	private Boolean attemptLogin(String user, String pass){
		return true;
	}
	
	public void onRegisterClick(View view) {
		Intent intent = new Intent(Login.this, Register.class);
		startActivity(intent);
	}

}
